<script type="text/javascript">
    var td_append_cur = 1;
    var tr_cur = 1;
    var MaxCountDiv = 1;
    
    stFacebookToolbox.sortColumn();
    stFacebookToolbox.shortAction();
    stFacebookToolbox.dataPostFilter = function(data_post){
        var folder = '<?php echo $current_folder ?>';
        if((data_post['folder'] == '' || data_post['folder'] == null) && folder != ''){
            data_post['folder'] = '<?php echo $current_folder ?>' ;
        }
    }
    stFacebookToolboxcustom.on_submitform_new('#uploadObject');
    stFacebookToolboxcustom.on_submitform_new('#editObject');
    stFacebookToolbox.pagingCallbackFunction = function(data){
        data['category_id'] = jQuery('#filter_cat').val();
    };

    stFacebookToolbox.sortCallbackFunction = function(data){
        data['category_id'] = jQuery('#filter_cat').val();
        data['cur_page'] = jQuery('#cur_page_id').val();
    }
    jQuery(document).ready(function(){
        //        jQuery('div.stExtra').html('');
        jQuery('.stExtra').remove();
        jQuery('#folder tr.click').click(function(){
            var action = 'appPostcards';
            var data = new Array();
            data['folder'] = jQuery(this).attr('folder');            
            stFacebookToolbox.loadPage(action, data);            
        });
        jQuery(".gallery1 a[rel^='prettyPhoto']").prettyPhoto({
            theme:'facebook',
            keyboard_shortcuts: false
        });
        
        jQuery('#filter_cat').change(function(){
            var action = '<?php echo $current_action1 ?>';
            var data = new Array();
            data['category_id'] = jQuery(this).val(); 
            stFacebookToolbox.loadPage(action, data);              
        });
        
        jQuery('#num_faces').change(function(){   
            MaxCountDiv = jQuery(this).val(); 
        });
        
    });
    
    

    //    stFacebookToolbox.loadUploadButton(null, null, null, 100, 1);
    stFacebookToolbox.loadRemoveButton();
    
    function toggleDiv(id, id1){
        jQuery('#editObject table tbody tr').each(function(){
            var trId = '#'+jQuery(this).attr('id');
            var tdId = jQuery(this).attr('id').replace('object_', 'shortEdit_');
            //            alert(jQuery(this).attr('id'));
            if(jQuery('#'+tdId).css('display') != 'none'){                
                cancelShortEdit(trId, tdId)
            }
        });
        if(jQuery('.'+id).css('display') == 'none'){
            jQuery('.'+id).fadeIn('slow');
            jQuery('#'+id1).css('display','block');
            
        }else{
            
            jQuery('.'+id).fadeOut('slow', function (){
                jQuery('#'+id1).css('display','none');
            });        
        }
        stFacebookToolbox.loadUploadButton(null, null, function(thumbnail_width, file_url, clickedID, clickedObject, file){
            imageSelectArea(thumbnail_width, file_url, clickedID, clickedObject, file, 'uploadObject');
            resetFaces('uploadObject', clickedID);
        }, 100, 1);
        stFacebookToolbox.loadUploadButton(null, null, null, 32, false, '.upload_logo');
    }
    
    function shortEdit(id, tr_id, name, thumb_url, description, num_faces, url, faces, cat_id, photographer, back_card_text, logo_url, featured){
        //        back_card_text = back_card_text.replace('<br>', '\n');
                
        MaxCountDiv = num_faces;
        countDiv = 0;
        jQuery('#uploadObject').css('display', 'none');
        jQuery('#editObject table tbody tr').each(function(){
            var trId = '#'+jQuery(this).attr('id');
            var tdId = jQuery(this).attr('id').replace('object_', 'shortEdit_');
            //            alert(jQuery(this).attr('id'));
            if(jQuery('#'+tdId).css('display') != 'none'){                
                cancelShortEdit(trId, tdId)
            }
        });
        var select1 = '';
        var select2 = '';
        var select3 = '';
        var select4 = '';
        switch(num_faces){
            case '1':
                select1 = "selected";
                break;
            case '2':
                select2 = "selected";
                break;
            case '3':
                select3 = "selected";
                break;
            case '4':
                select4 = "selected";
                break;
        }
        
        var data ='<ul id="shortEdit_'+id+'">';
        data +='<li>';
        data +='<label><?php _e('Name', $config['plugin_name']); ?>:</label>';
        data +='<div class="required">';
        data +='<input tabindex="1"  value="'+name+'" class="required" name="data[name]" id="name" type="text"/>';
        data +='</div>';
        data +='<br clear="both" />';
        data +='</li>';
        
        data +='<li>';
        data +='<label><?php _e('Photographer', $config['plugin_name']); ?>:</label>';
        data +='<div class="">';
        data +='<input tabindex="1"  value="'+photographer+'" class="" name="data[photographer]" id="photographer" type="text"/>';
        data +='</div>';
        data +='<br clear="both" />';
        data +='</li>';
        
        data +='<li>';
        data +='<label><?php _e('Number of faces', $config['plugin_name']); ?>:</label>';
        data +='<div class="required">';
        data +='<select onchange="MaxCountDiv = jQuery(this).val(); " class="required" id="num_faces" name="data[num_faces]" tabindex="2">';
        data +='<option '+select1+' value="1">1 Face</option>';
        data +='<option '+select2+' value="2">2 Faces</option>';
        data +='<option '+select3+' value="3">3 Faces</option>';
        data +='<option '+select4+' value="4">4 Faces</option>';
        data +='</select>';
        data +='</div>';
        data +='<br clear="both" />';
        data +='</li>';
        
        data +='<li>';
        data +='<label><?php _e('Category', $config['plugin_name']); ?>:</label>';
        data +='<div class="required">';
        data +='<select class="required" id="cat_id" name="data[cat_id]" tabindex="3">';
        data +='<option value="">Choose an category</option>';
<?php
foreach ($categories as $value) {
    echo "if(cat_id == '{$value->id}'){
                    current_cat= 'selected';
                    }else{current_cat= '';}";
    echo "data +='<option '+current_cat+' value=\"{$value->id}\">{$value->title}</option>';\n";
}
?>
                data +='</select>';
                data +='</div>';
                data +='<br clear="both" />';
                data +='</li>';
        
                // add 20-1-2011
                if(featured == 1){
                    is_featured1 = 'checked';
                    is_featured2 = '';
                }else{
                    is_featured2 = 'checked';
                    is_featured1 = '';
                }
                data +='<li>';
                data +='<label><?php _e('Is featured', $config['plugin_name']); ?>:</label>';
                data +='<div>';
                data +='<input '+is_featured1+' value="1" class="required" name="data[featured]" id="featured" type="radio" tabindex="5" />';
                data +='<label><?php _e('Yes', $config['plugin_name']) ?></label>';
                data +='<input '+is_featured2+' value="0" class="required" name="data[featured]" id="featured1" type="radio" tabindex="6" />';
                data +='<label><?php _e('No', $config['plugin_name']) ?></label>';
                data +='</div>';
                data +='<br clear="both" />';
                data +='</li>';       
                // add 20-1-2011
        
                data +='<li>';
                data +='<label><?php _e('Upload file', $config['plugin_name']); ?>:</label>';
                data +='<div class="required">';
                data +='<input value="'+thumb_url+'" class="required" name="data[upload_file]" id="id_upload_file'+id+'" type="hidden"/>';
                data +='<div class="upload_button_div">';
                data +='<span id="upload_file'+id+'" class="button image_upload_button">Upload Image</span>';
                data +='<span pictureID="upload_file'+id+'" id="reset_upload_file" class="button image_reset_button">Remove</span>';
                data +='</div> ';
                data +='<img alt="" src="'+thumb_url+'" id="image_upload_file'+id+'" class="hide preview" style="display: inline;">';
                data +='</div>';
                data +='<br clear="both" />';
                data +='</li>';
        
                data +='<li>';
                data +='<label><?php _e('Upload logo file', $config['plugin_name']); ?>:</label>';
                data +='<div class="">';
                data +='<input value="'+logo_url+'" class="" name="data[logo_file]" id="id_logo_file'+id+'" type="hidden"/>';
                data +='<div class="upload_button_div">';
                data +='<span id="logo_file'+id+'" class="button upload_logo">Upload Logo</span>';
                data +='<span pictureID="logo_file'+id+'" id="reset_logo_file" class="button image_reset_button">Remove</span>';
                data +='</div> ';
                if(logo_url != '')
                    data +='<img alt="" src="'+logo_url+'" id="image_logo_file'+id+'" class="hide preview" style="display: inline;">';
                data +='</div>';
                data +='<br clear="both" />';
                data +='</li>';
        
                data +='<li>';
                data +='<label><?php _e('Description', $config['plugin_name']); ?>:</label>';
                data +='<div class="">';
                data +='<textarea class="" name="data[description]" cols="5" rows="5" id="description" tabindex="2" >'+description+'</textarea>';
                data +='</div>';
                data +='<br clear="both" />';
                data +='</li>';
        
                data +='<li>';
                data +='<label><?php _e('Backside text', $config['plugin_name']); ?>:</label>';
                data +='<div class="">';
                data +='<textarea class="" name="data[back_card_text]" cols="5" rows="5" id="back_card_text" tabindex="3" >'+back_card_text+'</textarea>';
                data +='</div>';
                data +='<br clear="both" />';
                data +='</li>';
        
                data +='<li>';
                data +='<input type="submit" value="Submit"/>';
                data +='<input type="button" value="Close" onclick="cancelShortEdit(\''+tr_id+'\', \'shortEdit_'+id+'\')" />';
                data +='</li>';
                data +='</ul>';  
                data +='<div class="imageArea">';
                data +='<img alt="" src="'+url+'" id="image_upload_file'+id+'_select_area">';
                data += '</div>';
                data += '<input type="hidden" value="'+id+'" id="id" name="data[id]"/>';
                data += '<input type="hidden" value="<?php echo $config['bucket_name'] ?>" id="bucket_name" name="data[bucket_name]"/>';
                //data += '<input type="hidden" value="'+description+'" id="description" name="data[user_id]"/>';
                //        data += '<input type="hidden" value="'+description+'" id="description" name="data[description]"/>';
                data += '<input type="hidden" value="1" id="upload_opject" name="upload_opject"/>';
        
                jQuery(tr_id).fadeOut('fast', function(){
                    jQuery(tr_id+' td').each(function(){
                        jQuery(this).css('display','none');
                    });
                    jQuery(tr_id).append('<td colspan="8" id="shortEdit_'+id+'">'+data+'</td>');
                    jQuery(tr_id).fadeIn('fast', function(){
                        stFacebookToolbox.loadUploadButton(null, null, function(thumbnail_width, file_url, clickedID, clickedObject, file){
                            imageSelectArea(thumbnail_width, file_url, clickedID, clickedObject, file, 'editObject');
                            resetFaces('editObject', clickedID);
                        }, 100, 1, '#upload_file'+id);
                        stFacebookToolbox.loadUploadButton(null, null, null, 32, false, '.upload_logo');
                        //                stFacebookToolbox.loadUploadButton(null, null, null, 100, 1);
                        stFacebookToolbox.loadRemoveButton();
                        clickedID = 'upload_file'+id;
                        jQuery('img#image_'+clickedID+'_select_area').imgAreaSelect({
                            handles: true, 
                            autoHide: true,
                            onSelectEnd: function(img, selection){
                                if(countDiv < MaxCountDiv){
                                    imageSeletecAreaLoad(selection, clickedID, 'editObject');
                                }else{
                                    alert('Number of faces limit by '+MaxCountDiv)
                                }
                            }
                        });
                        faces = faces.split('|*|');
                        for (i =0; i< faces.length; i++) {
                            face = faces[i].split(',');
                            var selection = {
                                x1: face[0],
                                y1: face[1],
                                width:  face[2],
                                height: face[3]
                            }          

                            imageSeletecAreaLoad(selection, clickedID, 'editObject');
                        }
                        jQuery('#upload_file'+id).click();  
                        jQuery('.upload_logo').click();  
                    });
            
                }); 
                td_append_cur = 'shortEdit_'+id;
                tr_cur = tr_id;
        
            }
    
            function cancelShortEdit(tr_id, td_append){
                td_append_cur = '';
                tr_cur = '';
                jQuery('#'+td_append).remove();
                jQuery(tr_id+' td').each(function(){
                    jQuery(this).css('display','');
                });
            }
    
            function basename(path, suffix) {
                return path.replace(/\\/g,'/').replace( /.*\//, '' );
            }
    
            function getLargeImage(url, type){
                var name1 = basename(url);
                var name = basename(url);
        
                name = name.split('.');
        
                name = name[0]+'-'+type+'.'+name[1];
        
                url = url.replace(name1, name);
                return url;
            }
            var countDiv = 0;
            var countID = 0;
    
            function imageSelectArea(thumbnail_width, file_url, clickedID, clickedObject, file, formId){
                var file_new_url = getLargeImage(file_url, 'thumb');
                var file_large_url = getLargeImage(file_url, 'large');
                var buildReturn = '<img class="hide preview" id="image_'+clickedID+'" src="'+file_new_url+'" alt="" />';
                var buildReturnFull = '<img class="" id="image_'+clickedID+'_select_area" src="'+file_large_url+'" alt="" />';
                jQuery(".upload-error").remove();
                jQuery("#image_" + clickedID).remove();
                clickedObject.parent().after(buildReturn);
                jQuery('img#image_'+clickedID).fadeIn();
                //        alert("#"+formId+" .imageArea");
                jQuery("#"+formId+" .imageArea").html(buildReturnFull);
                jQuery("#"+formId+" .imageArea").fadeIn();
        
                jQuery('img#image_'+clickedID+'_select_area').imgAreaSelect({
                    handles: true, 
                    autoHide: true,
                    onSelectEnd: function(img, selection){
                        if(countDiv < MaxCountDiv){
                            imageSeletecAreaLoad(selection, clickedID, formId);
                        }else{
                            alert('Number of faces limit by ' +MaxCountDiv)
                        }
                    }
                });
        
                clickedObject.next('span').fadeIn();
                clickedObject.parent().prev('input').val(file);
            }    
    
            function imageSeletecAreaLoad(selection, clickedID, formId){
                if(selection.width > 20 && selection.height > 20){
                    imgposition = selection.x1+','+selection.y1+','+selection.width+','+selection.height
                    input1 = "<input id='newdiv_"+clickedID+countID+"_input' type='hidden' value='"+imgposition+"' name='data[faces][]' />"
                    jQuery("#"+formId).append(input1);
                    newDiv = '<div id="newdiv_'+clickedID+countID+'" class="facePosition"></div>'
                    jQuery("#"+formId+" .imageArea").append(newDiv);
                    jQuery("#newdiv_"+clickedID+countID).css('left', selection.x1+'px');
                    jQuery("#newdiv_"+clickedID+countID).css('top', selection.y1+'px');
                    jQuery("#newdiv_"+clickedID+countID).css('width', selection.width+'px');
                    jQuery("#newdiv_"+clickedID+countID).css('height', selection.height+'px');
                    jQuery("#newdiv_"+clickedID+countID).click(function(){
                        jQuery(this).remove();    
                        jQuery("#"+jQuery(this).attr('id')+'_input').remove();
                        countDiv--;
                    });
                    countDiv++;
                    countID++;
                }else{
                    //            alert('Width and height of face must be larger than 20 pixel')
                }
        
            
        
            }
    
            function resetFaces(fromId, clickedID){
                for(i = 0; i< countID; i++){
                    //            jQuery("#newdiv_"+clickedID+countID).remove();    
                    jQuery("#"+"newdiv_"+clickedID+i+'_input').remove();
                    countDiv--;
                }
                countID = 0;
                countDiv = 0;
            }
    
            // Add 20-1-2011
            stFacebookToolboxcustom.switchButton(null, function(data){
                jQuery("#data_featured_"+data['card_id']).val(data['featured']);
        
            });
    
            function savePriority(){
                //        alert(tr_cur);
                if( tr_cur != '' && td_append_cur != '')
                    cancelShortEdit(tr_cur, td_append_cur);

                //        var action = '<?php echo $current_action1 ?>';
                //        var data = new Array();
                //        jQuery('input.priority').each(function(){
                //            jQuery(this).attr('name', 'data[priority]['+jQuery(this).attr('card_id')+']');
                //        });   
                jQuery('form#editObject').append('<input type="hidden" value="change_priority" name="short_action" />');
                jQuery('#editObject').submit();  
            }
    
            function changePriority(id, priority){
                if( tr_cur != '' && td_append_cur != '')
                    cancelShortEdit(tr_cur, td_append_cur);
                jQuery('#priority'+id).val(priority);
                addAttrName('#priority'+id);
                savePriority();
            }
    
            function addAttrName(input){
                jQuery(input).attr('name', 'data[priority]['+jQuery(input).attr('card_id')+']');
            }
    
<?php if ($current_action1 == 'appPostcardsFeatured') { ?>
        jQuery('div.filter ').append('<input onclick="savePriority()" type="button" style="width: 120px; color: green; font-weight: bold; cursor: pointer; float:right;" class="button update_price" value="UPDATE PRIORITY">');
        jQuery.validator.addMethod("notEqual", function(value, element, param) {
            return this.optional(element) || value !== param;
        }, "Please choose a value!");
<?php } ?>
    
</script>

<div class="upload_field">
    <br clear="both" />
    <form class="stform" id="uploadObject" style="display: none;"  action="<?php echo admin_url('/admin.php?page=' . $config['plugin_name'] . '&action=' . $current_action1) ?>" method="post" >
        <ul>
            <li>
                <label><?php _e('Name', $config['plugin_name']); ?>:</label>
                <div class="required">
                    <input tabindex="1"  value="" class="required" name="data[name]" id="name" type="text"/>
                </div>
                <br clear="both" />
            </li>
            <li>
                <label><?php _e('Photographer', $config['plugin_name']); ?>:</label>
                <div class="">
                    <input tabindex="1"  value="" class="" name="data[photographer]" id="photographer" type="text"/>
                </div>
                <br clear="both" />
            </li>
            <li>
                <label><?php _e('Number of faces', $config['plugin_name']); ?>:</label>
                <div class="required">
                    <select class="required" id="num_faces" name="data[num_faces]" tabindex="2">
                        <option value="1">1 Face</option>
                        <option value="2">2 Faces</option>
                        <option value="3">3 Faces</option>
                        <option value="4">4 Faces</option>
                    </select>
                </div>
                <br clear="both" />
            </li>
            <li>
                <label><?php _e('Category', $config['plugin_name']); ?>:</label>
                <div class="required">
                    <select class="required" id="cat_id" name="data[cat_id]" tabindex="3">
                        <option value="">Choose an category</option>
                        <?php
                        foreach ($categories as $value) {
                            echo "<option value='{$value->id}'>{$value->title}</option>";
                        }
                        ?>
                    </select>
                </div>
                <br clear="both" />
            </li>

            <li>
                <label><?php _e('Is featured', $config['plugin_name']); ?>:</label>
                <div>
                    <input value="1" class="required" name="data[featured]" id="featured" type="radio" tabindex="5" />
                    <label><?php _e('Yes', $config['plugin_name']) ?></label>
                    <input checked value="0" class="required" name="data[featured]" id="featured1" type="radio" tabindex="6" />
                    <label><?php _e('No', $config['plugin_name']) ?></label>
                </div>
                <br clear="both" />
            </li>

            <li>
                <label><?php _e('Upload file', $config['plugin_name']); ?>:</label>
                <div class="required">
                    <?php
                    $class_hide = "hide";
                    ?>
                    <input value="" class="required" name="data[upload_file]" id="id_upload_file" type="hidden"/>
                    <div class="upload_button_div">
                        <span id="upload_file" class="button image_upload_button">Upload Image</span>
                        <span pictureID="upload_file" id="reset_upload_file" class="button image_reset_button <?php echo $class_hide ?>">Remove</span>
                    </div>                               
                </div>
                <br clear="both" />
            </li>

            <li>
                <label><?php _e('Upload logo file', $config['plugin_name']); ?>:</label>
                <div class="">
                    <?php
                    $class_hide = "hide";
                    ?>
                    <input value="" class="" name="data[logo_file]" id="id_logo_file" type="hidden"/>
                    <div class="upload_button_div">
                        <span id="logo_file" class="button upload_logo">Upload Logo</span>
                        <span pictureID="logo_file" id="reset_logo_file" class="button image_reset_button <?php echo $class_hide ?>">Remove</span>
                    </div>                               
                </div>
                <br clear="both" />
            </li>

            <li>
                <label><?php _e('Description', $config['plugin_name']); ?>:</label>
                <div class="">
                    <textarea class="" name="data[description]" cols="5" rows="5"
                              id="description" tabindex="2" ></textarea>
                </div>
                <br clear="both" />
            </li>
            <li>
                <label><?php _e('Backside text', $config['plugin_name']); ?>:</label>
                <div class="">
                    <textarea class="" name="data[back_card_text]" cols="5" rows="5"
                              id="back_card_text" tabindex="2" ></textarea>
                </div>
                <br clear="both" />
            </li>

            <li>
                <input type="submit" value="Submit"/>
                <input type="button" value="Close" onclick="jQuery('.upload_field').fadeOut()" />
            </li>
        </ul>
        <div class="imageArea"></div>
        <input type="hidden" value="" id="id" name="data[id]"/>                    
        <input type="hidden" value="<?php echo $config['bucket_name'] ?>" id="bucket_name" name="data[bucket_name]"/>
        <input type="hidden" value="1" id="upload_opject" name="upload_opject"/>
        <br clear="both" /><br clear="both" />
    </form>
</div>
<div class="filter float_right" style="margin: 5px 15px 5px 5px" >
    <label>Filter:</label>
    <select class="required" id="filter_cat">
        <option value="">Show All</option>
        <?php
        foreach ($categories as $value) {
            if ($current_category_id == $value->id) {
                $cur = "selected";
            } else {
                $cur = "";
            }
            echo "<option {$cur} value='{$value->id}'>{$value->title}</option>";
        }
        ?>
    </select>    
</div>
<br clear="both"/>
<div class="postcardBlock ">
    <form class="stform" id="editObject" style="padding: 0"  action="<?php echo admin_url('/admin.php?page=' . $config['plugin_name'] . '&action=' . $current_action1) ?>" method="post" >
        <table class="widefat " cellspacing="0">
            <thead>
                <tr>
                    <?php print_column_headers('stFacebookToolbox_stPostcards'); ?>
                </tr>
            </thead>
            <tbody>
                <?php
                if (count($objects) > 0) {
                    $tr_class = "";
                    $uploadDir = wp_upload_dir();
                    $i = 0;
                    foreach ($objects as $value) {
                        $time = explode(' ', $value->cdate);
                        $date = explode('-', $time[0]);
                        $date = $date[2] . '.' . $date[1] . '.' . $date[0];
                        $time = $time[1];

                        $cdate = $date . ' ' . $time;
                        if (empty($tr_class) || $tr_class == "class='bg_gray2'") {
                            $tr_class = "class='bg_gray1'";
                        } else {
                            $tr_class = "class='bg_gray2'";
                        }
                        if ($current_folder != $config['folder_template']) {
                            $td_extra = "<td>" . $value->customer_name . "</td>";
                        }
//                        echo $current_bucket;
                        $status = $value->featured == 1 ? 'cb-enable' : 'cb-disable';
                        if ($current_folder != $config['folder_template']) {

                            $viewed = empty($value->viewed) ? 0 : $value->viewed;
                            $shared_fb = empty($value->shared_fb) ? 0 : $value->shared_fb;
                            $shared_email = empty($value->shared_email) ? 0 : $value->shared_email;
                            $shared = $shared_fb + $shared_email;
                            $back_url = "";
                            if (!empty($value->back_url)) {
                                $back_url = "<a title='' href='{$value->back_url}' rel=\"prettyPhoto\">"
                                        . "<img height='70' src='" . $value->back_thumb_url . "' alt=''>"
                                        . "</a>";
                            }
                            $td_extra2 = "<td>$back_url</td>"
                                    . "<td align='center'> $viewed </td>"
                                    . "<td align='center'> $shared </td>"
                                    . "<td align='center'> $shared_fb </td>"
                                    . "<td align='center'> $shared_email </td>"
                            ;
                        } else {
                            $logo_url = '';
                            $td_extra2 = '<td></td>';
                            if (!empty($value->logo_file)) {
                                $td_extra2 = "<td><img height='70'  src=' {$uploadDir['baseurl']}{$value->logo_file}' /> </td>";
                                $logo_url = $uploadDir['baseurl'] . $value->logo_file;
                            }
                            if ($current_action1 == 'dashboardPostcard') {
                                $td_extra2 = '';
                            }

                            $td_extra2 .= "<td align='center'> $value->nr_created </td>"
                                        . "<td align='center' >"
                                        . "<div data_card_id='{$value->id}' data_short_action='set_featured' class='{$status} switch_checkbox'>"
                                        . "</div>"
                                        . "</td>"
                                        ;
                        }

                        $thumb_url = '';
                        if (!empty($value->thumb_url)) {
                            $thumb_url = "<a title='' href='{$value->url}' rel='prettyPhoto'>"
                                    . "<img height='70' src='" . $value->thumb_url . "' >"
                                    . "</a>";
                        }

                        $back_card_text = stripcslashes($value->back_card_text);
                        $description = stripcslashes($value->description);
                        
                        // 20-7-0211
                        $priority_td = "";
                        if ($current_action1 == 'appPostcardsFeatured') {
                            $priority = $value->priority == null ? 0 : $value->priority;
                            $priority_next = $priority + 1;
                            $priority_back = $priority - 1;
                            if ($priority_back <= 0) {
                                $priority_back = 1;
                            }
                            $priority_td = "<td>
                            <input notEqual='0' onchange='addAttrName(this)' card_id='{$value->id}' value='{$priority}' id='priority{$value->id}' class='priority' /> 
                            <span onclick='changePriority(\"{$value->id}\", \"{$priority_back}\")' class=\"icon_up\"></span>
                            <span onclick='changePriority(\"{$value->id}\", \"{$priority_next}\")' class=\"icon_down\"></span>
                            </td>";
                        }
                        echo "<tr $tr_class id='object_{$value->id}' >"
                        . "<td>" . $value->name
                        . "<div class=\"row-actions short_action\">"
                        ;
                        if ($current_folder == $config['folder_template']) {
                        echo "<span function='
                                        id = jQuery(\"#data_id_{$value->id}\").val();
                                        id_object = jQuery(\"#data_id_object_{$value->id}\").val();
                                        name = jQuery(\"#data_name_{$value->id}\").val();
                                        var thumb_url = \"{$value->thumb_url}\";
                                        description = jQuery(\"#data_description_{$value->id}\").val();
                                        num_faces = jQuery(\"#data_num_faces_{$value->id}\").val();
                                        url = jQuery(\"#data_url_{$value->id}\").val();
                                        faces = jQuery(\"#data_faces_{$value->id}\").val();
                                        cat_id = jQuery(\"#data_cat_id_{$value->id}\").val();
                                        photographer = jQuery(\"#data_photographer_{$value->id}\").val();
                                        back_card_text = jQuery(\"#data_back_card_text_{$value->id}\").val();
                                        var logo_url = \"$logo_url\";
                                        var featured = jQuery(\"#data_featured_{$value->id}\").val();

                                        shortEdit(id, id_object, name, thumb_url, description, num_faces, url, faces, cat_id, photographer, back_card_text, logo_url, featured)' 
                                        class='edit' short_action='edit' id='$value->id'>Edit | </span>";
                        }
                        echo "<span class='trash' short_action='delete' id='$value->id' confirm='Are you sure you want to delete this object?'>Trash </span>"
                        . "</div>"
                        . "</td>"
                        . "<td>" . $value->category_title . "</td>"
                        . $td_extra
                        //                                    . "<td>" . $value->file_name . "</td>"
                        . "<td>"
                        . $thumb_url
                        . "</td>"
                        . $td_extra2
                        
                        //                                    . "<td>" . $value->photographer . "</td>"
                        . $priority_td
                        . "<td>" . $cdate . "</td>"
                        . "<input type='hidden' id='data_id_{$value->id}' value='{$value->id}'/>"
                        . "<input type='hidden' id='data_id_object_{$value->id}' value='#object_{$value->id}'/>"
                        . "<input type='hidden' id='data_name_{$value->id}' value='{$value->name}'/>"
                        . "<input type='hidden' id='data_logo_url_{$value->id}' value='{$logo_url}'/>"
                        . "<input type='hidden' id='data_thumb_url_{$value->id}' value='{$value->thumb_url}'/>"
                        . "<textarea style='display:none' id='data_description_{$value->id}'>{$description}</textarea>"
                        . "<input type='hidden' id='data_num_faces_{$value->id}' value='{$value->num_faces}'/>"
                        . "<input type='hidden' id='data_url_{$value->id}' value='{$value->url}'/>"
                        . "<input type='hidden' id='data_faces_{$value->id}' value='{$value->faces}'/>"
                        . "<input type='hidden' id='data_cat_id_{$value->id}' value='{$value->cat_id}'/>"
                        . "<input type='hidden' id='data_photographer_{$value->id}' value='{$value->photographer}'/>"
                        . "<textarea style='display:none' id='data_back_card_text_{$value->id}'>{$back_card_text}</textarea>"
                        . "<input type='hidden' id='data_featured_{$value->id}' value='{$value->featured}'/>"
                        . "</tr>"
                        ;
                        $i++;
                    }
                }
                ?>
            </tbody>
        </table>
        <input type="hidden" value="<?php echo $cur_page ?>" name="cur_page" id="cur_page_id" />
    </form>
</div>
<div class="page_d">
    <?php echo $pagination ?>
    <div class="cl"></div>
</div>
<br clear="both" />